import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { UserService } from './user.service';
import { CreateUserDto } from '../dto/create-user.dto';
import { query } from 'express';

@ApiTags('用户')
@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  /**
   * 创建用户
   * @param user
   */
  @ApiOperation({ summary: '创建用户' })
  @Post('/register')
  async create(@Body() user: CreateUserDto) {
    return this.userService.register(user);
  }

  /**
   * 登录
   */
  @ApiOperation({ summary: '登录' })
  @Post('/login')
  async login(@Body() query) {
    debugger;
    return this.userService.login(query);
  }

  /**
   * 查询用户详情
   */
  @ApiOperation({ summary: '查询用户' })
  @Get('getUserInfo')
  async findOne(@Query('id') id) {
    return this.userService.getUserInfo(id);
  }
}
